<?php

class application_forms_Register extends Zend_Form{

public $adresse;
public $password;
public $password1;
public $civilite;
public $nom;
public $prenom;
public $date_de_naissance;
public $lieu_de_naissance;
public $quartier;
public $sexe;
public $numero_telephone;
public $image;
public $nom_pere;
public $fonction_pere;
public $numero_pere;
public $email_pere;
public $nom_mere;
public $fonction_mere;
public $numero_mere;
public $email_mere;
public $ecolelist;
public $classelist;
public $serielist;
public $annee;
public function __construct($options = null){
        parent::__construct($options);
        // initialize form
        $this->setName('registration')
        ->setAction('Valider')
        ->setMethod('post');
                $emptyValidator = new Zend_Validate_NotEmpty();
                $emptyValidator->setMessage(("All the fields are required"));
                $emailValidator = new Zend_Validate_EmailAddress();
                $emailValidator->setMessage(('E-mail must be a valid'));
                $primaryValidator = new Zend_Validate_Db_NoRecordExists('Profiles', 'Email');
                $primaryValidator->setMessage(("E-mail adress already in use"), Zend_Validate_Db_Abstract::ERROR_RECORD_FOUND);
                $stringLengthValdiator = new Zend_Validate_StringLength(6, 12);
                $stringLengthValdiator->setMessage(('Password must have 6 to 12 caracters'));
                $this->adresse = new Zend_Form_Element_Text('email');
                $this->adresse     ->setLabel(('Email'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'email')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                                ->addValidator(new Zend_Validate_Alnum());
                 // pour le mot de passe
                $this->password = new Zend_Form_Element_Password('password');
                $this->password ->setLabel(('Password'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required validate-password')
                                ->setAttrib('maxlength', 100)
                                ->setAttrib('id', 'password')
                                ->setRequired(true)
                        ->addValidator($emptyValidator);
               $this->password1 = new Zend_Form_Element_Password('password1');
               $this->password1    ->setLabel(('Password'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required validate-passverify')
                                ->setAttrib('maxlength', 100)
                                ->setAttrib('id', 'password1')
                                ->setRequired(true)
                                ->addValidator($emptyValidator);
                        if (isset($_POST['password'])) {
                        $passwordVerificationValidator = new Zend_Validate_Identical($_POST['password']);
                        $passwordVerificationValidator  ->setMessage(('Password does not match !'));
                        $this->password1->addValidator($passwordVerificationValidator);
                        }
                   // civilité de l'étudiant
                $this->civilite = new Zend_Form_Element_radio('civilite');
                $this->civilite ->setLabel(('Civilite'))
                ->setMultiOptions(array('0'=>'M', '1'=>'Mme','2'=>'Mlle'));
                //nom de l'étudiant
                $this->nom = new Zend_Form_Element_Text('nom');
                $this->nom     ->setLabel(('Nom'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'nom')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
                 // prenom
                $this->prenom = new Zend_Form_Element_Text('prénom');
                $this->prenom     ->setLabel(('Prénom'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'prénom')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
               //date de naissance
               $this->date_de_naissance = new Zend_Form_Element_Text('date_de_naissance');
               $this->date_de_naissance
                        ->setLabel(('Date de naissance(yyyy-mm-dd)'))
                        ->setAttrib('size', 40)
                        ->setAttrib('class', 'inputbox required')
                        ->setAttrib('maxlength', 50)
                        ->setAttrib('id', 'date_de_naissance')
                        ->setRequired(true)
                        ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator);
              // lieu de naissance
              $this->quartier= new Zend_Form_Element_Text('quartier');
              $this->quartier
                                ->setLabel(('Lieu de naissance'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'quartier')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
             // sexe
             $this->sexe = new Zend_Form_Element_Select('sexe');
             $this->sexe      ->setLabel(('Sexe'))
                                ->setAttrib('id', 'sexe')
                                ->setAttrib('style', 'width:315px')
                                ->setRequired(true)
                                ->addValidator($emptyValidator);
                                $this->sex->addMultiOption("","Je suis...");
                                $this->sex->addMultiOption("homme","Homme");
                                $this->sex->addMultiOption("femme","Femme");
            // lieu de résisdence
            $this->lieu_de_resisdence = new Zend_Form_Element_Text('lieu_de_resisdence');
            $this->lieu_de_resisdence     ->setLabel(('Lieu de resisdence'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'lieu de resisdence')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
          // téléphone étudiant
          $this->numero_telephone = new Zend_Form_Element_Text('numero_telephone');
          $this->numero_telephone
                                ->setLabel(('Telephone'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'numero_telephone ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
         // photo
            $this->image = new Zend_Form_Element_File('image');
           $this->image
                                ->setLabel(('Image'))
                                // Fait en sorte qu'il y ait un seul fichier
                               ->addValidator('Count', false, 1)
                                // limite à 100K
                                ->addValidator('Size', false, 102400)
                                // seulement des JPEG, PNG, et GIFs
                                ->addValidator('Extension', false, 'jpg,png,gif')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
         //pour les parents
           // coordonnées du père
          $this->nom_pere = new Zend_Form_Element_Text('nom_pere');
          $this->nom_pere
                                ->setLabel(('Nom du père'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'nom_pere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
           $this->fonction_pere = new Zend_Form_Element_Text('fonction_pere');
           $this->fonction_pere
                                ->setLabel(('Fonction du père'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'fonction_pere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
            $this->numero_pere = new Zend_Form_Element_Text('numero_pere');
            $this->numero_pere
                                ->setLabel(('Numéro du père'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'numero_pere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
           $this->email_pere = new Zend_Form_Element_Text('email_pere');
           $this->email_pere
                                ->setLabel(('Email du père'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'email_pere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
            // coordonnées de la mère
          $this->nom_mere = new Zend_Form_Element_Text('nom_mere');
          $this->nom_mere
                                ->setLabel(('Nom de la mère'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'nom_mere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
           $this->fonction_mere = new Zend_Form_Element_Text('fonction_mere');
           $this->fonction_mere
                                ->setLabel(('Fonction de la mère'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'fonction_mere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
            $this->numero_mere = new Zend_Form_Element_Text('numero_mere');
            $this->numero_mere
                                ->setLabel(('Numéro de la mère'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'numero_mere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
           $this->email_mere = new Zend_Form_Element_Text('email_mere');
           $this->email_mere
                                ->setLabel(('Email de la mère'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'email_mere ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
         // coordonnées relatives au choix de l'établissement
         // annee
         $this->annee = new Zend_Form_Element_Text('annee');
         $this->annee
                                ->setLabel(('Année'))
                                ->setAttrib('size', 40)
                                ->setAttrib('class', 'inputbox required')
                                ->setAttrib('maxlength', 50)
                                ->setAttrib('id', 'annee ')
                                ->setRequired(true)
                                ->addFilter('StripTags')
                        ->addFilter('StringTrim')
                        ->addValidator($emptyValidator)
                        ->addValidator(new Zend_Validate_Alnum());
         // choix d'une école
         $this->ecolelist = new Zend_Form_Element_Select('ecolelist');
         $this->ecolelist      ->setLabel(('Etablissement'))
                                ->setAttrib('id', 'ecolelist')
                                ->setAttrib('style', 'width:315px')
                                ->setRequired(true)
                                ->addValidator($emptyValidator);
                                $this->sex->addMultiOption("","Selectionnez une école");
                                $this->sex->addMultiOption("istdi","ISTDI");
                                $this->sex->addMultiOption("CES","CES");
         // choix d'une classe
         $this->classelist = new Zend_Form_Element_Select('classelist');
         $this->classelist      ->setLabel(('Classe'))
                                ->setAttrib('id', 'classelist')
                                ->setAttrib('style', 'width:315px')
                                ->setRequired(true)
                                ->addValidator($emptyValidator);
                                $this->sex->addMultiOption("","Selectionnez une classe");
                                $this->sex->addMultiOption("première","Première");
                                $this->sex->addMultiOption("seconce","Seconde");
         // choix d'une série
         $this->serielist = new Zend_Form_Element_Select('serielist');
         $this->serielist      ->setLabel(('Serie'))
                                ->setAttrib('id', 'serielist')
                                ->setAttrib('style', 'width:315px')
                                ->setRequired(true)
                                ->addValidator($emptyValidator);
                                $this->sex->addMultiOption("","Selectionnez une série");
                                $this->sex->addMultiOption("a","A");
                                $this->sex->addMultiOption("b","B");
        $submit = new Zend_Form_Element_Submit('valider');
        $submit->setAttrib('class', 'button validate')
        ->setLabel(('Valider'));
         // create captcha
        $captcha = new Zend_Form_Element_Captcha('captcha', array(
                        'captcha' => array(
                                'captcha' => 'Image',
                                'wordLen' => 5,
                                'timeout' => 300,
                                'width' => 170,
                                'height' => 60,
                                'imgUrl' => '',
                                'imgDir' => '',
                                'LineNoiseLevel' => '0',
                                'DotNoiseLevel' =>'0',
                                'font' => '',
                        )
                ));
        $captcha->setLabel('Verification:');
      $this->addElements(array($this->adresse, $this->password, $this->password1, $this->civilite,$this->nom, $this->prenom, $this->date_de_naissance, $this->lieu_de_naissance, $this->sexe, $this->quartier,$this->numero_telephone,$this->image,$this->nom_pere,$this->fonction_pere,$this->numero_pere,$this->email_pere,$this->nom_mere,$this->fonction_mere,$this->numero_mere,$this->email_mere,$this->annee,$this->ecolelist,$this->classelist,$this->serielist, $captcha, $submit));
  }
}
?>